<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" id="text" />
    <button>提交</button>
    <ul></ul>
    <script>
      var btn = document.querySelector('button')
      var text = document.querySelector('#text')
      var ul = document.querySelector('ul')
      btn.onclick = function () {
        var li = document.createElement('li')
        var textValue = text.value

        li.innerHTML = `${textValue} <a href = 'javascript:;' onclick = del1(this)>删除</a>`
        ul.appendChild(li)
        // console.log(li)
        text.value = ''
      }
      function del1(obj) {
        obj.parentNode.remove()
        // console.log(obj.parentNode)
      }
    </script>
  </body>
</html>
